home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- global proc int animImportOptions ( string $parent,
- string $action,
- string $initialSettings,
- string $resultCallback )
- //
- // Description:
- // This script posts the anim file accessor options.
- //
- // Parameters:
- // $parent - the elf parent layout for this options layout. It is
- // always a scrollLayout.
- // $action - the action that is to be performed with this invokation
- // of this proc. Valid options are:
- // "query" - construct the options string and pass it
- // to the resultCallback.
- // "post" - post all the elf controls.
- // $resultCallback -
- // This is the proc to be called with the result string.
- // resultCallback ( string $optionsString )
- //
- // Returns:
- // 1 if successfull.
- // 0 otherwise.
- //
- {
- int $result;
- string $currentOptions;
- string $optionList[];
- string $optionBreakDown[];
- int $index;
-
- if ($action == "post") {
- setUITemplate -pushTemplate DefaultTemplate;
- setParent $parent;
-
- columnLayout -adj true animMultiObjCol;
-
- radioButtonGrp
- -numberOfRadioButtons 4
- -label "Time Range"
- -label1 "Start"
- -cc1 ("floatFieldGrp -e -enable true animStartTime; " +
- "floatFieldGrp -e -enable false animEndTime; " +
- "updateAnimImportOptionsEnable;")
- -label2 "Start/End"
- -cc2 ("floatFieldGrp -e -enable true animStartTime; " +
- "floatFieldGrp -e -enable true animEndTime; " +
- "updateAnimImportOptionsEnable;")
- -label3 "Current"
- -cc3 ("floatFieldGrp -e -enable false animStartTime; " +
- "floatFieldGrp -e -enable false animEndTime; " +
- "updateAnimImportOptionsEnable;")
- -label4 "Clipboard"
- -cc4 ("floatFieldGrp -e -enable false animStartTime; " +
- "floatFieldGrp -e -enable false animEndTime; " +
- "updateAnimImportOptionsEnable;")
- animTimeRange;
-
- floatFieldGrp -label "Start Time" -value1 0.0 animStartTime;
- floatFieldGrp -label "End Time" -value1 10.0 animEndTime;
-
- intSliderGrp -label "Copies" -field true -min 1 -value 1 animCopies;
-
- separator -style "in" -w 1000;
-
- checkBoxGrp -label "Help Images" -ncb 1 -value1 off -l1 ""
- -cc1 "animImportHelpPictures;"
- animHelpPictures;
-
- radioButtonGrp
- -numberOfRadioButtons 3
- -label "Clipboard Adjustment"
- -label1 "Preserve" -cc1 "updateAnimImportOptionsEnable"
- -label2 "Scale" -cc2 "updateAnimImportOptionsEnable"
- -label3 "Fit" -cc3 "updateAnimImportOptionsEnable"
- animAdjustment;
-
- radioButtonGrp
- -numberOfRadioButtons 3
- -label "Paste Method"
- -label1 "Insert" -cc1 "updateAnimImportOptionsEnable"
- -label2 "Replace" -cc2 "updateAnimImportOptionsEnable"
- -label3 "Merge" -cc3 "updateAnimImportOptionsEnable"
- animMethod;
-
- radioButtonGrp
- -numberOfRadioButtons 2
- -label "Replace Region"
- -label1 "Time Range" -cc1 "updateAnimImportOptionsEnable"
- -label2 "Entire Curve" -cc2 "updateAnimImportOptionsEnable"
- animReplace;
-
- checkBoxGrp -label "Connect"
- -label1 "" -cc1 "animImportHelpPictures" animConnect;
-
- columnLayout -columnAttach "left" 10;
- picture animHelpPicture;
-
-
- // Now set to current settings.
- //
- $currentOptions = $initialSettings;
- if (size($currentOptions) > 0) {
- tokenize($currentOptions, ";", $optionList);
- for ($index = 0; $index < size($optionList); $index++) {
- tokenize($optionList[$index], "=", $optionBreakDown);
-
- if ($optionBreakDown[0] == "targetTime") {
-
- int $whichTime = $optionBreakDown[1];
- radioButtonGrp -edit -select $whichTime animTimeRange;
- floatFieldGrp -e -enable
- ($whichTime == 1 || $whichTime == 2) animStartTime;
- floatFieldGrp -e -enable ($whichTime == 2) animEndTime;
-
- } else if ($optionBreakDown[0] == "time") {
-
- string $time = $optionBreakDown[1];
- string $range[];
- tokenize ($time, ":", $range);
-
- // Only one time
- //
- if( size( $range ) == 1 ) {
- floatFieldGrp -edit -value1
- (float( $range[0] )) animStartTime;
- floatFieldGrp -edit -value1
- (float( $range[0] )) animEndTime;
- }
- // A time range
- //
- else if( size( $range ) > 1 ) {
- floatFieldGrp -edit -value1
- (float( $range[0] )) animStartTime;
- floatFieldGrp -edit -value1
- (float( $range[1] )) animEndTime;
- }
-
- } else if ($optionBreakDown[0] == "copies") {
- int $copies = $optionBreakDown[1];
- intSliderGrp -e -value $copies animCopies;
- } else if ($optionBreakDown[0] == "option") {
- string $option = $optionBreakDown[1];
-
- // pasteInsert
- //
- if ($option == "insert") {
- radioButtonGrp
- -edit
- -select 1
- animAdjustment;
- radioButtonGrp
- -edit
- -select 1
- animMethod;
- radioButtonGrp
- -edit
- -select 1
- animReplace;
- }
- // scaleInsert
- else if ($option == "scaleInsert") {
- radioButtonGrp
- -edit
- -select 2
- animAdjustment;
- radioButtonGrp
- -edit
- -select 1
- animMethod;
- radioButtonGrp
- -edit
- -select 1
- animReplace;
- }
- // fitInsert
- else if ($option == "fitInsert") {
- radioButtonGrp
- -edit
- -select 3
- animAdjustment;
- radioButtonGrp
- -edit
- -select 1
- animMethod;
- radioButtonGrp
- -edit
- -select 1
- animReplace;
- }
- // replace
- else if ($option == "replace") {
- radioButtonGrp
- -edit
- -select 1
- animAdjustment;
- radioButtonGrp
- -edit
- -select 2
- animMethod;
- radioButtonGrp
- -edit
- -select 1
- animReplace;
- }
- // replaceCompletely
- else if ($option == "replaceCompletely") {
- radioButtonGrp
- -edit
- -select 1
- animAdjustment;
- radioButtonGrp
- -edit
- -select 2
- animMethod;
- radioButtonGrp
- -edit
- -select 2
- animReplace;
- }
- // scaleReplace
- else if ($option == "scaleReplace") {
- radioButtonGrp
- -edit
- -select 2
- animAdjustment;
- radioButtonGrp
- -edit
- -select 2
- animMethod;
- radioButtonGrp
- -edit
- -select 1
- animReplace;
- }
- // fitReplace
- else if ($option == "fitReplace") {
- radioButtonGrp
- -edit
- -select 3
- animAdjustment;
- radioButtonGrp
- -edit
- -select 2
- animMethod;
- radioButtonGrp
- -edit
- -select 1
- animReplace;
- }
- // pasteMerge
- else if ($option == "merge") {
- radioButtonGrp
- -edit
- -select 1
- animAdjustment;
- radioButtonGrp
- -edit
- -select 3
- animMethod;
- radioButtonGrp
- -edit
- -select 1
- animReplace;
- }
- // scaleMerge
- else if ($option == "scaleMerge") {
- radioButtonGrp
- -edit
- -select 2
- animAdjustment;
- radioButtonGrp
- -edit
- -select 3
- animMethod;
- radioButtonGrp
- -edit
- -select 1
- animReplace;
- }
- // fitMerge
- else if( $option == "fitMerge" ) {
- radioButtonGrp
- -edit
- -select 3
- animAdjustment;
- radioButtonGrp
- -edit
- -select 3
- animMethod;
- radioButtonGrp
- -edit
- -select 1
- animReplace;
- }
-
- } else if ($optionBreakDown[0] == "pictures") {
- int $picture = $optionBreakDown[1];
- checkBoxGrp -e -value1 $picture animHelpPictures;
- } else if ($optionBreakDown[0] == "copies") {
- int $connect = $optionBreakDown[1];
- checkBoxGrp -e -value1 $connect animConnect;
- }
- }
- }
-
- updateAnimImportOptionsEnable();
-
- setUITemplate -popTemplate;
- $result = 1;
- } else if ($action == "query") {
- $currentOptions += ";";
- $currentOptions +=
- ("targetTime=" + `radioButtonGrp -query -select animTimeRange`);
- $currentOptions += ";";
-
- int $whichTime = `radioButtonGrp -query -select animTimeRange`;
- if ($whichTime == 1) {
- $currentOptions +=
- ("time=" +
- string (`floatFieldGrp -query -value1 animStartTime`));
- $currentOptions += ";";
- } else if ($whichTime == 2) {
- $currentOptions += ("time=" +
- string (`floatFieldGrp -query -value1 animStartTime`) +
- ":" + string(`floatFieldGrp -query -value1 animEndTime`));
- $currentOptions += ";";
- } else if ($whichTime == 3) {
- $currentOptions += ("time="+`currentTime -q`);
- $currentOptions += ";";
- }
-
- $currentOptions +=
- ("copies=" + `intSliderGrp -query -value animCopies`);
- $currentOptions += ";";
-
- string $option = "";
- int $selected = `radioButtonGrp -query -select animAdjustment`;
- if ($selected == 2) {
- $option = "scale";
- } else if ($selected == 3) {
- $option = "fit";
- }
-
- $selected = `radioButtonGrp -query -select animMethod`;
- if ($selected == 1) {
- if ($option == "") {
- $option += "insert";
- } else {
- $option += "Insert";
- }
- } else if ($selected == 2) {
- if ($option == "") {
- $option += "replace";
- } else {
- $option += "Replace";
- }
-
- if(`radioButtonGrp -query -select animReplace` == 2) {
- $option += "Completely";
- }
- } else if ($selected == 3) {
- if ($option == "") {
- $option += "merge";
- } else {
- $option += "Merge";
- }
- }
-
- $currentOptions += ("option=" + $option);
- $currentOptions += ";";
-
- $currentOptions +=
- ("pictures=" + `checkBoxGrp -query -value1 animHelpPictures`);
- $currentOptions += ";";
-
- $currentOptions += ("connect=" + `checkBoxGrp -q -value1 animConnect`);
- $currentOptions += ";";
-
- eval($resultCallback+" \""+$currentOptions+"\"");
- $result = 1;
- } else {
- $result = 0;
- }
-
- return $result;
- }
-
- global proc animImportHelpPictures()
- {
- int $doPictures = `checkBoxGrp -q -value1 animHelpPictures`;
- if( $doPictures == 0 ) {
- picture -e -visible no animHelpPicture;
- return;
- }
-
- int $adjustment = `radioButtonGrp -q -select animAdjustment`;
- int $method = `radioButtonGrp -q -select animMethod`;
- int $connect = `checkBoxGrp -q -value1 animConnect`;
- int $isFromClipboard = (`radioButtonGrp -q -select animTimeRange` == 4);
-
- string $helpPicture = "CCPpaste";
-
- if($adjustment == 1) {
- if($isFromClipboard) {
- $helpPicture += "Clip";
- } else {
- $helpPicture += "Preserve";
- }
- } else if ($adjustment == 2) {
- $helpPicture += "Scale";
- } else {
- $helpPicture += "Fit";
- }
-
- if ($method == 1) {
- $helpPicture += "Insert";
- } else if ($method == 2) {
- $helpPicture += "Replace";
- if($isFromClipboard) {
- if(`radioButtonGrp -query -select animReplace` == 2) {
- $helpPicture += "Complete";
- } else {
- $helpPicture += "Range";
- }
- }
- } else {
- $helpPicture += "Merge";
- }
-
- if (($connect == 1 ) && ( `checkBoxGrp -q -enable animConnect`)) {
- $helpPicture += "Connect";
- }
-
- $helpPicture += ".xpm";
-
- picture -e -image $helpPicture -visible yes animHelpPicture;
- }
-
- global proc updateAnimImportOptionsEnable() {
- int $whichTimeRange = `radioButtonGrp -q -select animTimeRange`;
- int $isTimeRange = ($whichTimeRange == 2);
-
- // enable the ones that can accept time ranges
- //
- if($isTimeRange) {
- int $isPreserve = (`radioButtonGrp -q -select animAdjustment` == 1);
-
- radioButtonGrp -e -enable1 ( !$isTimeRange ) animAdjustment;
- radioButtonGrp -e -enable2 yes animAdjustment;
- radioButtonGrp -e -enable3 yes animAdjustment;
-
- // If we've disabled the "Preserve" option but it was selected,
- // select "Fit" instead.
- //
- if( $isPreserve && $isTimeRange ) {
- $isPreserve = false;
- radioButtonGrp -e -select 3 animAdjustment;
- }
-
- radioButtonGrp -e -enable1 (!$isPreserve) animMethod;
- radioButtonGrp -e -enable2 yes animMethod;
- radioButtonGrp -e -enable3 (!$isPreserve) animMethod;
-
- if( $isPreserve ) {
- radioButtonGrp -e -select 2 animMethod;
- }
- }
- // disable the ones that can't accept time ranges
- //
- else {
- int $isFromClipboard = (`radioButtonGrp -q -select animTimeRange` == 4);
-
- radioButtonGrp -e -enable1 yes -select 1 animAdjustment;
- radioButtonGrp -e -enable2 no animAdjustment;
- radioButtonGrp -e -enable3 no animAdjustment;
-
- radioButtonGrp -e -enable1 yes animMethod;
- radioButtonGrp -e -enable2 $isFromClipboard animMethod;
- radioButtonGrp -e -enable3 yes animMethod;
-
- if(( $whichTimeRange != 0 )
- && ( !$isFromClipboard )
- && ( `radioButtonGrp -q -select animMethod` == 2 ))
- {
- radioButtonGrp -e -select 1 animMethod;
- }
- }
-
- // The replace option is enabled if the replace method is selected.
- //
- int $isReplaceMethod = (`radioButtonGrp -q -select animMethod` == 2);
- int $enableReplaceCurve = ( !$isTimeRange && $isReplaceMethod );
-
- radioButtonGrp -e -enable $isReplaceMethod animReplace;
- radioButtonGrp -e -enable2 $enableReplaceCurve animReplace;
-
- if( !$enableReplaceCurve && (`radioButtonGrp -q -select animReplace` == 2) ) {
- radioButtonGrp -e -select 1 animReplace;
- }
-
- // The connect option is only enabled when the method is NOT "Merge"
- //
- checkBoxGrp -edit -enable
- (`radioButtonGrp -q -select animMethod` != 3) animConnect;
-
- animImportHelpPictures;
- }
-